import type echarts from "./echarts";

// todo: rename
export function getChartOption(
  done: number,
  left: number,
  title: string,
  subTitle?: string,
): echarts.EChartsCoreOption {
  return {
    tooltip: {
      trigger: "item",
      show: false,
    },
    title: {
      text: title,
      subtext: subTitle,
      left: "center",
      top: subTitle ? "37%" : "42%",
      textStyle: {
        fontSize: 14,
        fontWeight: "normal",
        color: "white",
      },
      subTextStyle: {
        color: "#696969",
      },
      itemGap: 2,
    },
    series: [
      {
        name: "Access From",
        type: "pie",
        radius: ["70%", "85%"],
        label: {
          show: false,
          position: "center",
        },
        data: [
          {
            value: done,
            name: "Search Engine",
            itemStyle: { color: "#1de700" },
          },
          {
            value: left,
            name: "Direct",
            itemStyle: { color: "#f0f0f0" },
          },
        ],
      },
    ],
  };
}
